<div class="page-body">
    <div class="row">
        <div class="col-xs-12 col-md-12">
            <div class="widget">
                <div class="widget-header bordered-bottom bordered-blue">
                    <span class="widget-caption">后台用户</span>
                </div>
                <div class="widget-body">
                    <div id="horizontal-form">
                        <form class="form-horizontal" role="form" method="post"
                              action="{:U('doEdit',array('user_id'=>$data['user_id']))}">
                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right">账号：</label>
                                <div class="col-sm-3">
                                    <input type="text" name="account" class="form-control" required
                                           value="{$data.account}">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label no-padding-right">角色：</label>
                                <div class="col-sm-3">
                                    <select class="form-control" required name="group_id">
                                        <eq name="Think.ACTION_NAME" value="add">
                                            <option value="0">请选择</option>
                                        </eq>
                                        <volist name="group" id="v">
                                            <eq name="v.id" value="$group_id">
                                                <option value="{$v.id}" selected>{$v.title}</option>
                                                <else/>
                                                <option value="{$v.id}">{$v.title}</option>
                                            </eq>
                                        </volist>
                                    </select>
                                </div>
                            </div>

                            <eq name="Think.ACTION_NAME" value="add">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label no-padding-right">密码：</label>
                                    <div class="col-sm-3">
                                        <input type="password" name="password" class="form-control" required>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label no-padding-right">确认密码：</label>
                                    <div class="col-sm-3">
                                        <input type="password" name="password_r" class="form-control" required>
                                    </div>
                                </div>
                            </eq>

                            <eq name="Think.ACTION_NAME" value="edit">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label no-padding-right"></label>
                                    <div class="col-sm-3">
                                        <div class="checkbox">
                                            <label>
                                                <input type="checkbox" name="pwd-reset" class="colored-success">
                                                <span class="text">重置密码</span>
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </eq>

                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <button type="button" class="btn btn-blue btn-submit">确认</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/admin/js/phpjs/strings/sha1.js"></script>
<script>
    $('.btn-submit').on('click', function () {
        var group_id = $('[name="group_id"]').val()
        if (group_id == 0) {
            alert('角色必须选择');
            return;
        }
        var password = $('[name="password"]').val();
        var password_r = $('[name="password_r"]').val();
        if (password != password_r) {
            alert('两次密码不一致');
            return;
        } else {
            $('[name="password"]').val(sha1(password));
            $('[name="password_r"]').val();
        }
        if ($('[name="pwd-reset"]').is(":checked")) {
            $('[name="pwd-reset"]').val(sha1(""));
        }

        $('form').submit();
    })
    ;
</script>